<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>268.丢失的数组</title>
</head>

<body>

</body>

<script>
    /**
     * @param {number[]} nums
     * @return {number}
     */
    var missingNumber = function (nums) {
        let sum = nums.reduce((a, b) => a + b);
        let n = nums.length;
        return n * (n + 1) / 2 - sum;
    };
    console.log(missingNumber([9, 6, 4, 2, 3, 5, 7, 0, 1]));
</script>

</html>